package com.tong.componentization;

import android.os.Bundle;

import androidx.databinding.DataBindingUtil;

import com.tong.componentization.databinding.ActivityMain1Binding;
import com.tong.lib_base.base.BaseActivity;
import com.tong.lib_base.ft_login.model.UserBean;
import com.tong.lib_base.ft_login.service.impl.LoginImpl;
import com.tong.lib_base.ft_main.service.impl.MainImpl;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/*测试类，暂时无用*/
public class MainActivity1 extends BaseActivity {

    private ActivityMain1Binding mBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = DataBindingUtil.setContentView(this,R.layout.activity_main1);
        mBinding.setActivity(this);
        EventBus.getDefault().register(this);
        MainImpl.getInstance().startMainActivity(this);
    }
    public void checkLogin(){
        if(!LoginImpl.getInstance().hasLogin()){
            LoginImpl.getInstance().login(this,"");
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onReceiveMsg(String message) {
        UserBean userInfo = LoginImpl.getInstance().getUserInfo();
        mBinding.textMessage.setText(userInfo.getUserAccount() + "  "+userInfo.getUserNickName()+"  "+userInfo.getUserPassword());
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}